<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>tile</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Le styles -->
      <link href="css/bootstrap.css" rel="stylesheet">
      <link href="css/bootstrap-responsive.css" rel="stylesheet">
      <link href="js/bootstrap.js" rel="stylesheet">

    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
</head>

<?php
include("/usr/local/apache2/htdocs/tile/lib/Tile.php");
include("/usr/local/apache2/htdocs/tile/lib/ImgStorage.php");
include('log4php/Logger.php');
$cfgfile = "/usr/local/apache2/htdocs/tile/admin/bootstrap/conf/config.ini";
$defarray = parse_ini_file($cfgfile, 1);
$qlogtag = $defarray["Tiles"]['qlogtag'];
Logger::configure($defarray["Series"]['qlogcfg']);
$logger = Logger::getLogger($qlogtag);
$host = $defarray["Tiles"]["host"];
$user = $defarray["Tiles"]["user"];
$pass = $defarray["Tiles"]["pass"];
$db = $defarray["Tiles"]["db"];
$dbh = new Sqlexecutor($host, $user, $pass, $db);
$s = new Tile($dbh);
$list = $s->getListBySeriesID(1);
$texture_arr = array(
    "marble"=>"大理石",
    "aa"=>"水磨石", 
);

$tile_id = $_REQUEST["tile_id"];
$tile_number = $_REQUEST["tile_number"];
$tile_length = $_REQUEST["tile_length"];
$tile_width = $_REQUEST["tile_width"];
$tile_texture = $_REQUEST["tile_texture"];
$tile_img = $_REQUEST["tile_img"];
$submit = $_REQUEST["submit"];
$tile_series = 1;
if($submit != "")
{
    $res = $s->updateTileByID($tile_number, $tile_length, $tile_width, $tile_texture, $tile_img, $tile_img, $tile_series, $tile_id);
    header('Location:test.php');
}
?>


<div id="myModal" class="modal hide fade">

<div class="modal-header">
<a class="close" data-dismiss="modal" >&times;</a>
<h3>新建瓷砖产品</h3>
</div>

<div class="modal-body">
<h4>请填写以下信息</h4>
<p>
<form method="post" enctype="multipart/form-data" class="form-horizontal" action="a.php">
<fieldset>
<div class="control-group">
<span class="help-inline">型号:</span>
<input type="text" name="tile_number" class="span1" placeholder="输入型号">
</div>

<div class="control-group input-prepend input-append">
<span class="help-inline">尺寸:</span>
<input type="text" name="tile_length" class="input-mini span1" placeholder="宽"><span class="add-on">mm</span>
<i class="icon-remove"></i>
<input type="text" name="tile_width" class="span1" placeholder="高"><span class="add-on">mm</span>
</div>

<div class="control-group" >
<span class="help-inline">材质:</span>
<select class="span2" name="tile_texture">
<option>请选择</option>
<option>大理石</option>
<option>水磨石</option>
<option>花岗岩</option>
<option>木质</option>
</select>
</div>

<div class="control-group input-prepend input-append" >
<span class="help-inline">类型:</span>
<select class="span2" name="tile_type">
<option>请选择</option>
<option>天花板砖</option>
<option>地板砖</option>
<option>腰线</option>
<option>墙砖</option>
</select>
</div>

<div class="control-group">
<label class="control-label" for="tile_img">上传图片,注意<a href="#" class="tooltip-test" title="请使用300x300,300x450,300x600,400x800mm图片">尺寸</a>:</label>
<div class="controls">
<input class="input-file" name="tile_img" id="tile_img" type="file">
</div>
</div>
</fieldset>
</p>
<hr>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal" >关闭</a>
<button type="submit" class="btn btn-primary">保存更改</button>
</div>
</form>
</div>

<a data-toggle="modal" href="#myModal" class="btn btn-primary btn-large">添加新瓷砖</a>

<div class="row">
<?php
$str = "";
foreach($list as $key => $value)
{ 
    $id = $value["id"];
    $number = $value["number"];
    $length = $value["length"];
    $width = $value["width"];
    $texture = $value["texture"];
    $img = $value["img"];

    $str .= '<div class="span4">
         <form class="well form-inline" target="_self">
         <input type="hidden" name="tile_id" class="span1" value="'.$id.'">
         <input type="hidden" name="tile_img" class="span1" value="'.$img.'">

         <div class="control-group input-prepend input-append">
         <ul class="thumbnails">
         <li class="span3">
         <a href="#" class="thumbnail">
         <img src="http://www.hongdouxiong.com/tile/img/'.$img.'" alt="">
         </a>
         </li>
         </ul>
         </div>

         <div class="control-group input-prepend input-append">
         <span class="help-inline">型号:</span>
         <input type="text" name="tile_number" class="span1" value="'.$number.'">
         </div> 

         <div class="control-group input-prepend input-append">
         <span class="help-inline">尺寸:</span>
         <input type="text" name="tile_length" class="input-mini span1" value="'.$length.'"><span class="add-on">mm</span>
         <i class="icon-remove"></i>
         <input type="text" name="tile_width" class="span1" value="'.$width.'"><span class="add-on">mm</span>
         </div>

         <div class="control-group input-prepend input-append" >
         <span class="help-inline">材质:</span>
         <select class="span2" name="tile_texture">
         <option value="">请选择</option>';
        foreach($texture_arr as $texture_idx => $texture_name)
        {
            if($texture_idx == $texture)
                $str .= '<option selected value="'.$texture_idx.'">'.$texture_name.'</option>';
            else
                $str .= '<option value="'.$texture_idx.'">'.$texture_name.'</option>';
        }
        $str .= '</select>
         </div>
         <div class="control-group input-prepend input-append" >
         <span class="help-inline">类型:</span>
         <select class="span2" name="tile_type">
         <option value="">请选择</option>
         <option selected value="tianhua">天花板砖</option>
         <option>地板砖</option>
         <option>腰线</option>
         <option>墙砖</option>
         </select>
         </div>

         <div class="control-group ">
         <span class="help-inline">经销商<a href="#" class="tooltip-test" title="这是根据您所有经销商设置的价格计算出来的平均值">均价</a>:</span>
         <input type="text" readonly class="span1" placeholder="100">
         </div>


         <button value="1" type="submit" name="submit" class="btn-mini" >修改</button>
         </form>
         </div>
         ';
    
}
echo $str;
?>
</div>

      <!-- Le javascript
      ================================================== -->
      <!-- Placed at the end of the document so the pages load faster
      <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> -->
      <script src="js/jquery.js"></script>
      <script src="js/google-code-prettify/prettify.js"></script>
      <script src="js/bootstrap-transition.js"></script>
      <script src="js/bootstrap-alert.js"></script>
      <script src="js/bootstrap-modal.js"></script>
      <script src="js/bootstrap-dropdown.js"></script>
      <script src="js/bootstrap-scrollspy.js"></script>
      <script src="js/bootstrap-tab.js"></script>
      <script src="js/bootstrap-tooltip.js"></script>
      <script src="js/bootstrap-popover.js"></script>
      <script src="js/bootstrap-button.js"></script>
      <script src="js/bootstrap-collapse.js"></script>
      <script src="js/bootstrap-carousel.js"></script>
      <script src="js/bootstrap-typeahead.js"></script>
      <script src="js/application.js"></script>
      <script src="js/customize.js"></script>

</html>
